#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int t, ans[25], p[25][MAXN], cnt2;
bool cnt[25][MAXN];

struct group {
    int n, m, l, v;
} r[25];

struct car {
    int d, v, a;
} c[25][MAXN];

int main() {
    memset(cnt, true, sizeof(cnt));
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> t;
    for (int i = 1; i <= t; i++) {
        cin >> r[i].n >> r[i].m >> r[i].l >> r[i].v;
        for (int j = 1; j <= r[i].n; j++) {
            cin >> c[i][j].d >> c[i][j].v >> c[i][j].a;
        }
        for (int j = 1; j <= r[i].m; j++) {
            cin >> p[i][j];
        }
        
        for (int j = 1; j <= r[i].n; j++) {            
            for (int k = 1; k <= r[i].m; k++) {
                double top = (r[i].v * r[i].v) - (c[i][j].v * c[i][j].v);
                double bottom = 2 * c[i][j].a;
                double rst = top / bottom;
                double dis = p[i][k] - c[i][j].d;

                if (c[i][j].a == 0) {
                    // fixed velocity. do not need to consider cctv cam.
                    if (c[i][j].v > r[i].v && c[i][j].d < p[i][k]) {
                        ans[i]++;
                        break;
                    }
                    else break;
                }

                // with acceleration.
                if (rst < dis) {
                    if (c[i][j].a > 0) cnt[i][k] = false;
                    else if (c[i][j].a < 0) {
                        for (int u = 1; u <= r[i].m; u++) {
                            double dis2 = p[i][u] - c[i][j].d;
                            if (rst >= dis2) cnt[i][k] = false;
                        }
                    }
                    ans[i]++;
                    break;
                }
            }
        }
        for (int j = 1; j <= r[i].m; j++) {
            if (cnt[i][j] == false) cnt2++;
        }
        cout << ans[i] << " " <<  cnt2 << endl;
    }

    return 0;
}